package leetcode;

/**
 * https://leetcode-cn.com/problems/two-sum/description/
 * https://leetcode.com/problems/two-sum/?tab=Description
 * @program: brushing
 * @description:
 * @author: LiuQiang
 * @create: 2018-07-25 10:33
 **/
public class TwoSum {
    public int[] twoSum(int[] nums, int target) {
        int ret[] = new int[2];
        for (int i = 0; i < nums.length; i++) {
            int flag = target - nums[i];
            for (int j = 0; j < nums.length; j++) {
                if (j != i && (nums[j] == flag)) {
                    if (i > j) {
                        ret[0] = j;
                        ret[1] = i;
                    } else {
                        ret[0] = i;
                        ret[1] = j;
                    }

                }
            }
        }
        return ret;
    }

    public static void main(String[] args) {
        TwoSum solution = new TwoSum();

        //int f[] = {3,2,3};
        int f[] = {};
        int a[] = solution.twoSum(f, 28);
        System.out.println(a[0] + " " + a[1]);
    }
}
